/**
 * 
 */
package tokens;

import java.util.ListIterator;
import java.util.Queue;
import java.util.Stack;

import nodes.AbstractNode;
import nodes.ConstantNode;

/**
 * @author Charlie Hatcher
 * 
 */
public class ConstantToken extends AbstractToken {
	private static final String CONSTANT_TOKEN = "-?[0-9]+(\\.[0-9]+)?";

	@Override
	public boolean matchToken(String str, ListIterator<String> it) {
		return str.matches(CONSTANT_TOKEN);
	}

	@Override
	public String toString() {
		return "Constant";
	}

	@Override
	public void handleParser(String str, ListIterator<String> it,
			Stack<AbstractBinaryToken> opStack,
			Queue<AbstractNode> outPutQueue, Queue<AbstractNode> queue)
			throws Exception {
		outPutQueue.add(new ConstantNode(Integer.valueOf(str), myModel));

	}

}
